var t = getApp();

Page({
    data: {
        enterpriseActiveName: "0",
        status: "3",
        first_list: [],
        total: "",
        current_page: "",
        thismonth: "",
        lastweek: "",
        yesterday: "",
        today: "",
        page: 1,
        total_page: "",
        isMore: !0
    },
    onLoad: function(t) {
        this.getData(this.data.status);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        console.log("下拉刷新"), this.getData(this.data.status);
    },
    onReachBottom: function() {
        this.data.isMore ? this.getMoreData(this.data.status) : wx.showToast({
            title: "没有更多了",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    getData: function(a) {
        var s = this;
        console.log(a, "6546566445646564");
        var e = {
            status: a,
            withdrawal_type: this.options.type,
            page: this.data.page
        }, i = t.getNetAddresss("finance.withdraw.withdraw-list");
        t._getNetWork({
            url: i,
            data: e,
            success: function(t) {
                if (1 == t.result) {
                    s.setData({
                        total: t.data.total,
                        current_page: t.data.current_page,
                        today: t.data.today,
                        yesterday: t.data.yesterday,
                        lastweek: t.data.lastweek,
                        thismonth: t.data.thismonth,
                        total_page: t.data.last_page
                    });
                    for (var a = t.data.data, e = 0; e < a.length; e++) 0 == a[e].status && (a[e].status = "未结算"), 
                    1 == a[e].status && (a[e].status = "已结算"), -1 == a[e].status && (a[e].status = "已失效");
                    s.setData({
                        first_list: a
                    });
                } else wx.showToast({
                    icon: "none",
                    title: t.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function(a) {
        var s = this, e = this.data.page;
        if (console.log(e, this.data.total_page, "11111"), e >= this.data.total_page) this.setData({
            isMore: !1
        }); else {
            e++, this.setData({
                page: e
            });
            var i = {
                status: a,
                withdrawal_type: this.options.type,
                page: e
            }, o = t.getNetAddresss("finance.withdraw.withdraw-list");
            t._getNetWork({
                url: o,
                data: i,
                success: function(t) {
                    if (1 == t.result) {
                        s.setData({
                            total: t.data.total,
                            current_page: t.data.current_page
                        });
                        for (var a = s.data.first_list.concat(t.data.data), e = 0; e < a.length; e++) 0 == a[e].status && (a[e].status = "未结算"), 
                        1 == a[e].status && (a[e].status = "已结算"), -1 == a[e].status && (a[e].status = "已失效");
                        s.setData({
                            first_list: a
                        });
                    } else wx.showToast({
                        icon: "none",
                        title: t.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    handleClick: function(t) {
        console.log(t.detail, "2121154541"), "2" == t.detail.index && this.setData({
            status: "0"
        }), "1" == t.detail.index && this.setData({
            status: "1"
        }), "0" == t.detail.index && this.setData({
            status: "3"
        }), "3" == t.detail.index && this.setData({
            status: "-1"
        }), this.getData(this.data.status);
    }
});